package cn.wolfcode.wolf2w.util;

import lombok.Getter;
import lombok.Setter;

@Getter
public enum RedisKeys {
    // 短信验证码的key 的唯一性
    VERIFY_CODE("verify_code",Consts.VERIFY_CODE_VAI_TIME * 60L),
    // 登录凭证 token
    LOGIN_TOKEN("login_token",Consts.USER_INFO_TOKEN_VAI_TIME * 60L),
    // 阅读数      约定时效 -1 为不时效
    STRATEGY_STATIS_VO("strategy_statis_vo",-1L),
    // 收藏数
    STRATEGY_STATIS_FAVORNUM("strategy_statis_favornum",-1L),
    // 置顶数
    STRATEGY_STATIS_THUMBNUM("strategy_statis_thumbnum",null);

    @Setter
    private String prefix;
    @Setter
    private Long time;

    private RedisKeys(String prefix, Long time){
        this.prefix = prefix;
        this.time = time;
    }
    // 限制拼接规范，考虑到有可能需要拼接的key是多个
    public String join(String... keys){
        StringBuilder sb = new StringBuilder();
        sb.append(prefix);
        for (String key : keys) {
            sb.append(":").append(key);
        }
        return sb.toString();
    }

}
